home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / texsis / Unix / TEXSIS08 / TXSrefs.tex (.txt) < prev    next >
LaTeX Document  |  1992-08-02  |  29KB  |  460 lines

  1. %% file: TXSrefs.tex                             TeXsis version 2.15
  2. %  $Revision: 15.3 $  :  $Date: 92/06/19 10:53:28 $  :  $Author: myers $
  3. %======================================================================*
  4. % REFERENCES -                   (C) copyright 1986, 1992 by Eric Myers
  5. %       These macros use TXStags to handle references with automatic
  6. % numbering. The references can either be typed in the body of the document
  7. % or collected at the beginning. In either case a new reference is defined
  8. %       \reference{<tag>} <text> \endreference
  9. % The <tag> can be almost anything, including a number. If it is *, then
  10. % the reference number is not incremented; this allows multiple references
  11. % with the same number. Otherwise, \reference causes the next available
  12. % reference number to be assigned to <tag>. It also saves the tag definition
  13. % in \jobname.aux, and saves the reference <text> in the file \jobname.ref
  14. % Of course, <text> is the desired
  15. % reference text, e.g. "D.~Knuth, {\sl The TeXbook}". The final punctuation
  16. % should NOT be typed in <text>; a . is added unless the next tag is *,
  17. % in which case a ; is added.
  18. %        If \reference ... \endreference is typed in the body of the document,
  19. % the reference number is printed. The default format is a superscript, but
  20. % this can be changed:
  21. %       \superrefstrue     ==>    superscript reference numbers
  22. %       \superrefsfalse    ==>    reference numbers in []
  23. % \endreference actually looks ahead at the next token; if it is another
  24. % \reference, then a range is printed instead of separate numbers.
  25. %       \referencelist ... \endreferencelist can be used to type all of the
  26. % references at the beginning of the document, with the format
  27. %       \referencelist
  28. %       \reference{<tag1>} <text1> \endreference
  29. %       \reference{<tag2>} <text2> \endreference
  30. %       ...
  31. %       \endreferencelist
  32. % While it is natural with this format to make the tag equal to the actual
  33. % reference number, this is not required.
  34. %       Subsequent references to a previously defined reference are obtained
  35. % with \cite{<tag>}.  Again this has a look-ahead feature so that several
  36. % consecutive \cite's give the reference numbers separated by commas. If the
  37. % references are typed at the beginning with \referencelist, then all
  38. % references in the text are made with \cite. If the <tag> is not defined,
  39. % then \cite produces an error, which is flagged both in the printed document
  40. % and on the log file. A \Ref{<tag>} macro (note the case) is also provided
  41. % to print Ref.~<number> in the text. Other forms can be constructed if
  42. % desired with \use{Ref.<tag>}; see the definition of \Ref.
  43. %       The list of references is printed with the macro \ListReferences
  44. % (or \References for backwards compatibility). To allow for multiple
  45. % references with the same number, \ListReferences adds a ; to the end of
  46. % a reference if the next tag is * and a . otherwise. Hence the final
  47. % punctuation should not be typed in the reference text. Note that
  48. % \ListReferencese does not print a heading, which should be inserted using
  49. % \chapter, \section, or the appropriate plain TeX commands.
  50. %       If \texsis is not called, then the reference text will be
  51. % written to the screen, and \ListReferences will fail to print the
  52. % appropriate text. If \auxswitchfalse is used, then the AUX file will
  53. % not be written, and the tag definitions will appear on the screen
  54. % (surrounded by \csname ... \endcsname). This causes no harm unless the
  55. % checkpoint/restart feature is used, in which case the earlier tag
  56. % definitions will not be remembered.
  57. % Dependencies: TXStags.tex     for reference labels
  58. %======================================================================*
  59. \message{References and Citations.}
  60. \catcode`@=11
  61. %       Counters, switches and I/O:
  62. \newcount\refnum        \refnum=\z@     % counter for reference numbers
  63. \newcount\@firstrefnum  \@firstrefnum=1 % first of a series of refs
  64. \newcount\@lastrefnum   \@lastrefnum=1  % last of a series of refs
  65. \newcount\@BadRefs      \@BadRefs=0     % count undefined references
  66. \newif\ifrefswitch      \refswitchtrue  % output references by default
  67. \newif\ifbreakrefs      \breakrefstrue  % line break between refs?
  68. \newif\ifsuperrefs      \superrefstrue  % print ref numbers as superscripts
  69. \newif\ifmarkit         \markittrue     % switch for "hidden" references
  70. \newif\ifnullname       \nullnamefalse  % switch for null or starred labels
  71. \newif\iftagit                          % switch for tagging references
  72. \newif\ifreffollows                     % switch for many \ref's
  73. \newif\ifrefpunct       \refpuncttrue   % automatic punctuation at end
  74. \def\refterminator{}                    % start with this null
  75. \newdimen\refindent     \refindent=2em  % indentation for references
  76. \newdimen\refpar        \refpar=20pt    % indentation for ref. paragraphs
  77. \newbox\tempbox                         % for getting \refindent
  78. %==================================================*
  79. %  INITIALIZATION.   \refinit performs first time reference initialization
  80. \newwrite\reflistout                    % output file for ref text
  81. \def\refinit{\ifrefswitch               % is .ref ouput enabled?
  82.    \immediate\openout\reflistout=\jobname.ref  % y: open .ref file for output
  83.   \else                                 % no:
  84.     \let\@refwrite=\@refwrong           %   disable output
  85.     \let\@refNXwrite=\@refwrong         %   disable output
  86.     \immediate\closeout\reflistout      % and make sure output closed
  87.   \fi                                   %
  88.   \gdef\refinit{\relax}%                % disable \refinit
  89. % \@refwrite{text} writes text to .ref file, while
  90. % \@refNXwrite{text} writes the text to the file without expanding it.
  91. \def\@refwrite#1{\refinit               % perform initialization, if needed
  92.    \immediate\write\reflistout{#1}}%    % write to .ref
  93. \def\@refNXwrite#1{\refinit             % initialize if needed
  94.    \unexpandedwrite\reflistout{#1}}%    % do unexpanded write
  95. % Write to SYS$DUMMY=/dev/null (i.e., thin air) if output disabled
  96. \def\@refwrong#1{}%             % sorry for the pun
  97. %==================================================*
  98. %  REFERENCE TEXT.
  99. %  \reference{lable} <text> \endreference defines a new reference entry
  100. \long\def\reference#1{% cite a new reference, with reference text
  101.   \markittrue                           % enable citation in output
  102.   \@tagref{#1}%                         % get next number and tag it
  103.   \@GetRefText{#1}%                     % write ref text to .ref file
  104.   }%                                    %   (and will cite when done)
  105. \long\def\addreference#1{% \reference without citation
  106.   \markitfalse                          % don't cite in output
  107.   \@tagref{#1}%                         % get a number and tag it
  108.   \@GetRefText{#1}%                     % write ref text to .ref file
  109.   }%                                    %
  110. \def\hiddenreference{\addreference}%    % backward compatability (v.2.02)
  111. %  \@tagref{label} assigns the next reference number to the label,
  112. %  unless the name begins with * or is null
  113. \def\@tagref#1{% assign a reference number to a tag
  114.   \stripblanks #1\endlist               % remove blanks. Result --> \tok
  115.   \XA\ifstar\tok*\fi                    % sets \nullnametrue if null or *'d
  116.   \ifnullname\relax\else                %   unless name is null
  117.     \global\advance\refnum by \@ne      % increment \refnum
  118.     \@lastrefnum=\refnum                %   and \@lastrefnum
  119.     \edef\rnum{\the\refnum}%            % \rnum is the ref number
  120.     \tag{Ref.#1}{\rnum}%                % tag the reference
  121.     \ifnum\pageno>\z@                   % if not on page 0, announce
  122.       \begingroup                       % make these local
  123.       \quoteoff\offparens               % make ",(, ), characters, not active
  124.       \immediate\write16{(\the\refnum) %% write comment to .LIS and terminal
  125.  First reference to "#1" on page \the\pageno.}%
  126.       \endgroup                         % " back to whatever it was
  127.     \fi                                 % end \ifnum
  128.   \fi                                   % end \ifnullname
  129. % \ifstar determines whether a tag begins with "*", and sets a flag
  130. \def\ifstar#1#2\fi{\ifx*#1\relax\nullnametrue\else\nullnamefalse\fi}
  131. %  \@GetRefText gets the reference text as everything up to the next
  132. %  \endreference and writes it to the .ref file.  #1 is the label.
  133. \def\@GetRefText#1{%                    % get and write reference text
  134.   \ifnullname                           % is name null (set by \@tagref)
  135.     \p@nctwrite;\relax                  % y: write ";" and line break
  136.     \begingroup\quoteoff                % turn off special "
  137.       \@refwrite{\@comment Reference text for %%
  138.       "#1" defined on page \number\pageno.}% 
  139.     \endgroup                           % let " be whatever it was
  140.   \else                                 % n: write "." and number
  141.     \ifnum\refnum>1                     % first reference?
  142.       \p@nctwrite.\fi                   % no: write trailing .
  143.     \begingroup\quoteoff\@parensoff     % turn off special ",),(
  144.       \@refwrite{\@comment }%           %
  145.       \@refwrite{\@comment (\the\refnum)}% write comment to .ref file
  146.       \@refwrite{\@comment Reference text for %%
  147.       "#1" defined on page \number\pageno.}%  
  148.     \endgroup                           % let " be whatever it was
  149.     \@refwrite{\NX\@refitem{\the\refnum}}%  write ref number to .ref
  150.   \fi                                   %
  151. %                                       % Write reference to .ref file
  152.   \begingroup                           % start group to write text
  153.    \def\endreference{\NX\endreference}% % def these to nothing
  154.    \def\reference{\NX\reference}%       %   so we can play with them
  155.    \def\ref{\NX\ref}%                   %   without using them
  156.    \obeylines                           % so ^M seen by \@copyref
  157.    \@copyref                            % copy text line to .ref file
  158. }%                                
  159. %  \@copyref gets the next line of text and sends it to \ParseRefText
  160. %  to scan for \endreference and act accordingly
  161. {\obeylines                                     % to see end of line
  162.  \gdef\@copyref#1
  163.    {\def\@arg{#1}\ifx\@arg\emtpy\relax\let\@nextline=\@copyref %% get next line
  164.     \else\ParseRefText#1\endreference\endreference\endlist\fi  %% PARSE line
  165.     \@nextline}%                                %% next iteration
  166. }%                                              % end \obeylines
  167. %  \ParseRefText looks at the line for \endreference. If it is present,
  168. %  then #1 is text before, #2 is text after, and #3 is \endreference. If it
  169. %  is not present then #2 and #3 are null, and #1 is the line.
  170. \def\ParseRefText#1\endreference#2\endreference#3\endlist{% parse \reference
  171.    \def\@arg{#1}\ifx\@arg\empty\relax           % if #1 null, don't write it
  172.    \else\begingroup                             % otherwise,
  173.      \@refNXwrite{#1}%                          % write unexpanded line
  174.      \endgroup                                  % ^^M, \@quote reset
  175.    \fi                                          %
  176.    \def\@arg{#3}\ifx\@arg\empty                 %
  177.         \let\@nextline=\@copyref                % if no \endreference, repeat
  178.    \else\let\@nextline=\@endcopyref             %   otherwise, exit loop
  179.      \gdef\@remainder{\@endreference #2}%       % save rest of line for later
  180.    \fi}%                                        % and do \@nextline
  181. \def\@endcopyref{\endgroup              % make \ref, etc... defs active again
  182.     \@remainder                         % do \@endreference on rest of line
  183.     }%      
  184. %  \@comment is for writing % to a file like the .ref file. It expands
  185. %  to the letter '%' and a space
  186. {\catcode`\%=11 \gdef\@comment{% }}
  187. \def\@parensoff{\catcode`\(=11 \catcode`\)=11}
  188. %  \@endreference is post processing (what user thinks is \endreference).
  189. %  \@endreference checks to see if another \reference follows. If not, it puts
  190. %  the citation mark in the output
  191. \long\def\@endreference#1{% end a \reference and look ahead at next token
  192.   \reffollowsfalse                              % assume no cit'ns follow
  193.   \ifx#1\cite\reffollowstrue\fi                 % is next token another \cite?
  194.   \ifx#1\refrange\reffollowstrue\fi             % or \refrange
  195.   \ifx#1\ref\reffollowstrue\fi                  % (or \ref, OLD TeXsis)
  196.   \ifx#1\reference\reffollowstrue               % if \reference set flag
  197.   \else                                         %     but nothing more
  198.    \ifnum\@firstrefnum>\@lastrefnum\relax       % If *'d \reference, \relax
  199.    \else\ifmarkit                               % so can we write citation?
  200. % --- construct the reference mark for this reference or range in \@refmark
  201.     \ifnum\@firstrefnum=\@lastrefnum            % is there only one reference?
  202.       \xdef\@refmark{\the\@lastrefnum}%         % yes: write only one number
  203.     \else                                       % no: write a 
  204.       \xdef\@refmark{\the\@firstrefnum-\the\@lastrefnum}% range of numbers
  205.     \fi                                         % end \ifnum
  206.     \global\@firstrefnum=\refnum                % reset \@firstrefnum to be
  207.     \global\advance\@firstrefnum by \@ne        %   \refnum + 1
  208.     \add@refmark                        % add \@refmark to \@refmarklist
  209.    \fi\fi                               % end \ifnum and \ifmarkit
  210.   \fi                                   % end \ifx#1\reference
  211.   \flush@reflist{#1}%                   % output ref mark list
  212.   #1}                                   % do the remaining #1 lookahead
  213. \def\endreference{% end the \reference text
  214.   \emsg{>  Whoops! \NX\endreference was called without
  215.   first calling \NX\reference.}\@errmark{REF?}% %
  216.   \emsg{>  I'll just ignore it.}%               %
  217.   }%                                            %
  218. \def\@refspace{\ }
  219. %  \space@head#1 takes the lookahead token from \@endreference or
  220. % \cite and does nothing if it is punctuation.  Otherwise it puts
  221. % in a \space.  It does not put the token back on the list! (the
  222. % calling macro does that.)  Note that in TeXsis ), ], and  " can
  223. % be active characters that have macro definitions, so they must
  224. % be handled separately.
  225. {\quoteon
  226. \gdef\space@head#1{\relax                       % #1 is from look-ahead
  227.    \def\sp@ce@head{\space}%                     % normally a space
  228.     \ifcat.\NX#1\relax\def\sp@ce@head{\relax}\fi      % no space if punct.
  229.     \ifx)#1\def\sp@ce@head{\relax}\fi           % no space if active )
  230.     \ifx]#1\def\sp@ce@head{\relax}\fi           % no space if active ]
  231.     \ifx"#1\def\sp@ce@head{\relax}\fi           % no space if active "
  232.    \sp@ce@head}%                                % space or nothing
  233. %  \citemark{#1} creates the superscript reference number using #1
  234. %  as the text. It is called by \endreference, or may be called by the user
  235. %  using \use to get the value of a tag. (NOTE: the tag is actually Ref.#1
  236. %  and not just #1, so say \use{Ref.label})
  237. \def\citemark#1{%                  output the citation marks in the text
  238.    \relax                                       % 
  239.    \ifhmode\edef\@sf{%                          % save spacefactor
  240.       \spacefactor\the\spacefactor}\/\fi        %
  241.    \ifsuperrefs                                 % superscript references?
  242.       $\relax{}^{\hbox{$\citestyle              % small numbers
  243.       #1\refterminator$}}$\relax                % superscript
  244.    \else {}~[{#1}]\relax\fi                     % [] style
  245.    \@sf}%                                       % restore spacefactor
  246. \def\citestyle{\scriptstyle}                    % default citation size
  247. %       Turn off \citemark output.  For typing a list of references all
  248. % together at the begining of a document.
  249. \def\referencelist{% begin a list of references at front of document
  250.    \begingroup                                  % make change to \citemark local
  251.    \pageno=0                                    % not a real page
  252.    \def\citemark##1{\relax}%                    % \citemark does nothing here
  253.    \def\@refspace{\relax}}                      % no spaces!!!
  254. \def\endreferencelist{% end \referencelist
  255.    \endgroup}                                    % all as it was
  256. %==================================================*
  257. %  CITATIONS.  \cite{<label>} cites a previously defined reference given
  258. %  by <label>. (There is only one user argument, #2 is for lookahead.)
  259. \long\def\cite#1#2{% cite a previous reference in the text 
  260.   \markittrue                                   % make sure output is on
  261.   \reffollowsfalse                              % assume no ref. follows
  262.   \ifx#2\cite\reffollowstrue\fi                 % is next token another \cite?
  263.   \ifx#2\refrange\reffollowstrue\fi             % or \refrange
  264.   \ifx#2\ref\reffollowstrue\fi                  % (or \ref, OLD TeXsis)
  265.   \ifx#2\reference\reffollowstrue\fi    % or is it \reference? then set flag.
  266.   \make@refmark{#1}%                    % make  reference mark in \@refmark
  267.   \add@refmark                          % add \@refmark to \@refmarklist
  268.   \flush@reflist{#2}%                   % flush \@refmarklist to output
  269.   #2}%                                  % do the remaining arg #2
  270. \let\ref=\cite                           % \ref is synonym (old TeXsis)
  271. \def\@refmarklist{}                      % start with nothing in list
  272. \gdef\refbef@re{F}                       % flag = no references before
  273. % \make@refmark takes the reference label and put the reference number
  274. % (if there is one) in \@refmark
  275. \def\make@refmark#1{% make a reference mark
  276.   \testtag{Ref.#1}\ifundefined           % is it undefined? (tag -> \tok)
  277.     \emsg{> UNDEFINED REFERENCE #1 ON PAGE \number\pageno.}% error message
  278.     \advance\@BadRefs by 1               % count undefined references
  279.     \xdef\@refmark{{\tenbf #1}}%         % cite with label in boldface
  280.     \@errmark{REF?}%                     % and mark error in output
  281.   \else                                  % no:
  282.     \xdef\@refmark{\csname\tok\endcsname}%  cite with number
  283.   \fi}                                   % end of \ifundefined
  284. %  \add@refmark adds \@refmark to the \@refmarklist
  285. \def\add@refmark{% add reference mark to accumulating list
  286.   \if\refbef@re T\relax                         % any previous citations?
  287.     \xdef\@refmarklist{\@refmarklist,\@refmark}%   yes: add on new one
  288.   \else                                         %
  289.     \xdef\@refmarklist{\@refmark}%              % no: just one mark
  290.     \gdef\refbef@re{T}%                         %  but now set the flag
  291.   \fi}
  292. % \flush@reflist flushes the \@refmarklist to the output.
  293. % #1 is the lookahead token, used to see if we need to add space afterwards.
  294. \long\def\flush@reflist#1{% flush list of references to output
  295.   \ifmarkit                              % is \markit set? Then write citation
  296.   \ifreffollows\else                     % Is there a following citation?
  297.     \citemark{\@refmarklist}%            % no: print citation
  298.     \gdef\refbef@re{F}%                  % reset flag and
  299.     \gdef\@refmarklist{}%                %  empty \@refmarklist
  300.     \ifx#1\par\else\space@head{#1}\fi    % insert possible space after
  301.   \fi\fi}                                % end \ifreffollows\ifmarkit
  302. %  \Ref{label} (note the case!) returns the reference number of a
  303. %  previously entered reference for use in text.  If you don't like
  304. %  the way this looks you can change it to suit yourself.
  305. \def\Ref#1{Ref.~\use{Ref.#1}}
  306. %       \refrange#1#2 cites a range of previously defined references like
  307. % \cite. #3 is a lookahead.
  308. \long\def\refrange#1#2#3{% cites a range of references
  309.   \reffollowsfalse                      % assume no ref. follows
  310.   \ifx#3\cite\reffollowstrue\fi         % is next token another \cite?
  311.   \ifx#3\ref\reffollowstrue\fi          % (or \ref, OLD TeXsis)
  312.   \ifx#3\reference\reffollowstrue\fi    % or is it \reference? then set flag.
  313.   \ifx#3\refrange\reffollowstrue\fi     % or \refrange
  314. % --- construct reference mark in \@refmark
  315.   \make@refmark{#2}%                    % ref mark for 2nd ref
  316.   \xdef\@refmarktwo{\@refmark}%         % save for later
  317.   \make@refmark{#1}%                    % ref mark for 1st ref
  318.   \xdef\@refmark{\@refmark-\@refmarktwo}% create range of references
  319.   \add@refmark                          % add to \@refmarklist
  320.   \flush@reflist{#3}%                   % flush output list
  321.   #3}%                                  % do the remaining #3 args
  322. %==================================================*
  323. %       The following macros are used in the reference text to print
  324. % properly volume numbers for journals, titles of books, etc.
  325. \def\NP{Nucl.\ Phys.}
  326. \def\PL{Phys.\ Lett.}
  327. \def\PR{Phys.\ Rev.}
  328. \def\PRL{Phys.\ Rev.\ Lett.}
  329. %  \vol{volume of journal} is used for the volume number of a journal
  330. %  article.  The number is underlined when printed. (Underscoring looks
  331. %  better than boldface on the laser printer.)
  332. \def\vol#1{\undertext{#1}}
  333. % \booktitle{title of book} prints book title in slanted type
  334. \def\booktitle#1{{\sl #1}}
  335. %  some other useful shorthand
  336. \def\etal{{\it et al.}}
  337. \def\ie{{\it i.e.}}
  338. \def\cf{{\it cf.}}
  339. \def\ibid{{\it ibid.}}
  340. %==================================================*
  341. %  LIST OF REFERENCES.   \ListReferences gets the list of references
  342. %  from the .ref file and adds it to the document.  \References is a
  343. %  synonym (from v.2.04).   No heading is printed; the user should add
  344. %  one with \chapter, \section, or whatever is appropriate.
  345. \def\ListReferences{\emsg{Reference List}%      % announce in .LIS file
  346.   \p@nctwrite.\relax                            % write last "." for last ref
  347.   \@refwrite{\@comment>>> EOF \jobname.ref <<<}%% and EOF marker comment
  348.   \immediate\closeout\reflistout        %  then close the .ref file
  349.   \ifnum\@BadRefs>\z@                   % any undefine references?
  350.     \emsg{>}\emsg{> There were \the\@BadRefs\ undefined references.}%
  351.     \emsg{> See the file \jobname.log for the citations, or try running}%
  352.     \emsg{> TeXsis again to resolve forward references.}\emsg{>}%
  353.   \fi                                           %
  354.   \begingroup                                   % now read in the .ref file
  355.     \catcode`@=11                               % make @ a letter
  356.     \offparens                                  % make sure )&) not active
  357.     \unobeylines                                % treat ^^M like whitespace
  358.     \setbox\tempbox\hbox{\the\refnum.\quad}%    % size of largest ref number?
  359.     \refindent=\wd\tempbox                      % refindent to handle this
  360.     \leftskip=\refindent                        % set up reference indent
  361.     \parindent=\z@                              % don't indent after breaking
  362.     \def\reference{\@noendref}%                 % in case of errors
  363.     \refFormat                                  % user definable format info
  364.     \Input\jobname.ref  \relax                  % read text from .ref file
  365.     \vskip 0pt                                  % needed to close \leftskip!
  366.   \endgroup                                     % close group
  367.   \emsg{}%                                      % Newline line in log
  368.   }%                                            % end of \References
  369. \def\References{\ListReferences}%               % synonym
  370. %  \refFormat is called just before the reference file is read in.
  371. %  It can contain instructions for formatting the reference list. For example,
  372. %  in two-column output it might be good to have it include a \raggedright.
  373. \def\refFormat{\relax}%
  374. \def\@noendref#1{%                                              %
  375.    \emsg{>  Whoops! \NX\reference{#1} was given before the}%    %
  376.    \emsg{>  \NX\endreference for the previous \NX\reference.}%  %
  377.    \emsg{>  I'll just ignore it and run the two together.}%     %
  378.    }%
  379. %  \@refitem starts a new reference, with the number in the left margin
  380. %  For use by \ListReferences when printing reference list.
  381. %  \refindent is the indentation for the main text (not the number).
  382. %  \refskip is the skip between references (default is \smallskip).
  383. \def\@refitem#1#2{\message{#1.}%   #2 looks past ^^M for next arg
  384.    \refskip\noindent\hskip-\refindent           % indent, but write number
  385.    \hbox to \refindent {\hss #1.\quad}%         % unindented
  386.    #2}
  387. \def\refskip{\smallskip}%                       % default skip
  388. %       \@refpunct gets the punctuation for the reference text and kills
  389. % the space and carriage return before it.
  390. \def\@refpunct#1{\unskip#1}%                    % remove space and print . or ;
  391. %   \p@nctwrite#1 writes punctuation #1 to .ref file only if \ifrefpunct
  392. %   is true.  Use this to turn off automatic punctuation of references.
  393. \def\p@nctwrite#1{%
  394.    \ifrefpunct                          % if switch is true
  395.       \@refwrite{\NX\@refpunct#1\NX\@refbreak}% % write #1 and line break
  396.    \else                                %  else
  397.       \@refwrite{\NX\@refbreak}%        % just write a break
  398.    \fi}
  399. %  \@refbreak causes a line break if \ifbreakrefs is true.
  400. \def\@refbreak{\ifbreakrefs\par\fi}
  401. %======================================================================*
  402. %      \journal simplifies typing journal references in technical papers
  403. % by providing automatic formatting and automatic correct treatment of
  404. % abbreviations.  By default typing
  405. %      \journal Phys. Rev. Lett.;vol;page(year)
  406. % produces
  407. %      Phys. Rev. Lett. vol, page (year)
  408. % All periods in name are followed by a single space as if you had typed
  409. % Phys.\ Rev.\ Lett.\ and the volume number is underlined.
  410. % If you first type
  411. %      \Eurostyletrue
  412. % then \journal produces
  413. %      Phys. Rev. Lett. vol (year) page
  414. % appropriate to European journals.  Note that the arguments to \journal
  415. % are ALWAYS in the American order.
  416. %      \journal can be used to define macros for specific journals, but
  417. % in this case all . MUST be typed as .\ because of the way that TeX
  418. % uses \catcodes for characters.
  419. %-----------------------------------------------------------------------
  420. \newif\ifEurostyle     \Eurostylefalse         % European style journals
  421. %   When . is active instead of punctuation it gives no space
  422. {\catcode`\.=\active                           % . is active
  423.    \gdef.{\hbox{\p@riod\null}}}                % . is .\null for abbrev
  424. \def\p@riod{.}                                 % normal period
  425. %      Define main macro \journal.  This turns on definition of . and
  426. % turns off easy parens, then does work with \j@ounal.
  427. \def\journal{% cite an article in a journal by volume, page and year
  428.   \bgroup                                       % keep \catcode's local
  429.    \catcode`\.=\active                          % make . active
  430.    \offparens                                   % turn off easy parens
  431.    \j@urnal}%                                   % and do work
  432. \offparens                                      % make sure ( and ) not active!
  433.  \def\j@urnal#1;#2,#3(#4){%  gets the \journal material
  434.    \ifEurostyle                                 %  choose style...
  435.       {#1} {\vol{#2}} (\@fullyear{#4}) #3\relax % European style
  436.    \else                                        % 
  437.       {#1} {\vol{#2}}, #3 (\@fullyear{#4})\relax % American style
  438.    \fi                                          %
  439.   \egroup}                                      % end group for . and ()
  440. % \@fullyear takes one argument, which is considered to be a year.
  441. % If it is less than 100 then it is an abreviation, so we add the
  442. % current century to it if it is less than or equal to THIS year,
  443. % otherwise we add the LAST century.  This should survive into
  444. % the next millenium.  Thanks to Scott Hannahs for this macro.
  445. \def\@fullyear#1{%
  446.   \begingroup                                   % make calculations local
  447.    \count255=\year                              % get current century
  448.       \divide \count255 by 100 \multiply \count255 by 100
  449.    \count254=\year                              % next year in this century
  450.       \advance \count254 by -\count255 \advance \count254 by 1
  451.    \count253=#1\relax                           % citation year
  452.    \ifnum\count253<100                          % year < 100 needs century
  453.      \ifnum \count253>\count254                 % high year 
  454.        \advance \count253 by -100\fi            %     means last century
  455.       \advance \count253 by \count255           % add centuries
  456.    \fi                                          %
  457.    \number\count253                             % display year
  458.   \endgroup                                     % end local calculations
  459. %>>> EOF TXSrefs.tex <<<
  460.